#ifndef _PARTSTORE_HPP_
#define _PARTSTORE_HPP_

#include "jhdefs.hpp"
#include "net/PartSource.hpp"
#include "stream/FileStream.hpp"
using JHCPP::stream::CFileStream;
#include <string>

NET_NAMESPACE_BEGIN

class CPartStore : public CPartSource
{
public:
	CPartStore(const std::string& mediaType);
	~CPartStore();

private:
	CPartStore();
};


class CFilePartStore : public CPartStore
{
public:
	CFilePartStore(const std::string& content, const std::string& mediaType, const std::string& filename = "");
	~CFilePartStore();

	std::istream& stream();
	const std::string& filename() const;
	const std::string& path() const;

private:
	std::string m_filename;
	std::string m_path;
	CFileStream m_fstr;
};


class CPartStoreFactory
{
public:
	virtual CPartSource* createPartStore(const std::string& content, const std::string& mediaType, const std::string& filename = "") = 0;
};


class CFilePartStoreFactory : public CPartStoreFactory
{
public:
	CPartSource* createPartStore(const std::string& content, const std::string& mediaType, const std::string& filename = "")
	{
		return new CFilePartStore(content, mediaType, filename);
	}
};

NET_NAMESPACE_END

#endif
